﻿using System;
using System.Collections;
using System.Linq;
using System.Text;

namespace Pakxel.Framework
{
    public class Data
    {
        public string Propiedad;
        public object Dato;

        public Data(string Property, object Data)
        {
            Propiedad = Property;
            Dato = Data;
        }
    }

    public class IEnumReport : IEnumerable
    {
        private Data[] _data;
        public IEnumReport(Data[] pArray)
        {
            _data = new Data[pArray.Length];

            for (int i = 0; i < pArray.Length; i++)
                _data[i] = pArray[i];
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return (IEnumerator)GetEnumerator();
        }

        public ReporteEnum GetEnumerator()
        {
            return new ReporteEnum(_data);
        }
    }

    public class ReporteEnum : IEnumerator
    {
        public Data[] _data;
        int position = -1;

        public ReporteEnum(Data[] list)
        {
            _data = list;
        }

        public bool MoveNext()
        {
            position++;
            return (position < _data.Length);
        }

        public void Reset()
        {
            position = -1;
        }

        object IEnumerator.Current
        {
            get { return Current; }
        }

        public Data Current
        {
            get
            {
                try { return _data[position]; }
                catch (IndexOutOfRangeException) { throw new InvalidOperationException(); }
            }
        }
    }
}
